package com.fastfood.controller;

import java.util.ArrayList;
import java.util.List;

import com.fastfood.model.blo.AccountBLO;
import com.fastfood.model.blo.RoleBLO;
import com.fastfood.model.dto.Account;
import com.fastfood.model.dto.Role;
import com.opensymphony.xwork2.ActionSupport;

public class AccountAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	
	private RoleBLO roleBLO;
	private AccountBLO accountBLO;
	
	private List<Account> listAccount;
	private List<Role> listRole;
	private Account account;
	
	public AccountAction() {
		roleBLO = new RoleBLO();
		accountBLO = new AccountBLO();
		listAccount = new ArrayList<Account>();
		listRole = new ArrayList<Role>();
	}
	
	public String list() {
		List<Account> listAccount = accountBLO.getAllAccounts();
		if (listAccount != null) this.listAccount = listAccount;
		List<Role> listRole = roleBLO.getAllRoles();
		if (listRole != null) this.listRole = listRole;
		return SUCCESS;
	}
	
	public String add() {
		accountBLO.addAccount(account);
		return SUCCESS;
	}
	
	public String update() {
		accountBLO.updateAccount(account);
		return SUCCESS;
	}
	
	public String delete() {
		accountBLO.deleteAccount(account);
		return SUCCESS;
	}
	
	public List<Account> getListAccount() {
		return listAccount;
	}
	
	public void setListAccount(List<Account> listAccount) {
		this.listAccount = listAccount;
	}
	
	public List<Role> getListRole() {
		return listRole;
	}
	
	public void setListRole(List<Role> listRole) {
		this.listRole = listRole;
	}
	
	public Account getAccount() {
		return account;
	}
	
	public void setAccount(Account account) {
		this.account = account;
	}
}
